<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link data-th-replace="commons::res">
<style type="text/css">
	body{
		padding: 15px
	}
</style>
</head>
<body>
	<form class="layui-form">
		<input type="hidden" name="id" data-th-value="${resourcetype?.id}">
		<div class="layui-form-item">
			<div class="layui-form-label">资源类型名称:</div>
			<div class="layui-input-block">
				<input type="text" class="layui-input" lay-verify="required" data-th-value="${resourcetype?.name}" name="name" placeholder="请输入资源类型名称">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-form-label">详情:</div>
			<div class="layui-input-block">
				<textarea name="describe" data-th-text="${resourcetype?.describe}" class="layui-textarea" placeholder="请输入资源类型详情,如:超级管理员拥有至高无上的权限">
				
				</textarea>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button type="button" lay-submit class="layui-btn" lay-filter='resourcetype'>保存</button>
			</div>
		</div>
	</form>
	<script type="text/javascript">
		layui.use(['form','jquery','layer'],function(){
			let form=layui.form
				,$=layui.jquery
				,layer=layui.layer;
			form.on("submit(resourcetype)",function(data){
				$.ajax({
					url:'[[@{/resource-type/save}]]',
					type:'post',
					dataType:'json',
					data:data.field,
					success:function(rs){
						if(rs.success){
							var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
							parent.reload();
							parent.layer.msg("保存成功",{icon:6});
							parent.layer.close(index);
							
						}else{
							layer.msg("保存失败",{icon:5});
						}
					}
				})
				return false;
			})
		})
	</script>
</body>
</html>